import { ARFactory } from '../axios_conf'
// eslint-disable-next-line
import { Method } from 'axios'

/**
 * 获取公众号菜单配置
 * @param {Object} config 额外配置
 * @param {Method} method 请求方法
 * @returns {Promise}
 */
function fetchMenuConfig(config = {}, method = 'GET') {
  const url = 'get_wx_menu'
  return ARFactory({ url, method, params: config })
}

/**
 * 设置公众号菜单
 * @param {Object} config 菜单配置文件
 * @param {Method} method 请求方法
 * @param {Object} headers 请求头
 * @returns {Promise}
 */
function setMenu(_config = {}, method = 'POST') {
  const url = 'wx_menu'
  return ARFactory({ url, method, data: _config })
}

/**
 * 微信公众号绑定
 * @param {{ appid, appsecret }} config 微信公众号基本配置
 * @param {Method} method 请求方式
 * @returns {Promise}
 */
function bindWX(config = { appid, appsecret }, method = 'POST') {
  const url = 'wx_bind'
  return ARFactory({ url, method, data: config })
}

/**
 * 获取微信公众号绑定信息
 * @param {Object} config 额外配置
 * @param {Method} method 请求方式
 * @returns {Promise}
 */
function bindWXInfo(config = {}, method = 'GET') {
  const url = 'wx_bind_info'
  return ARFactory({ url, method, data: config })
}

export { fetchMenuConfig, setMenu, bindWX, bindWXInfo }
